#include <iostream>
#include <vector>
using namespace std;

typedef pair<float, float> Point, Vector;
#define x first
#define y second
typedef struct
{
    Point p1, p2;
}Segment;

float ProVec(Vector v1, Vector v2)
{
    return (v1.x*v2.y - v2.x*v1.y);
}

Vector MakeVec(Point p1, Point p2)
{
    Vector ans;
    ans.x = p2.x - p1.x;
    ans.y = p2.y - p1.y;
    return ans;
}
int main()
{
    vector<Segment> seg;
    int num;
    while (cin >> num && num!=0)
    {
        int ans = 0;
        Segment tmp;
        for (int i=0; i<num; ++i)
        {
            cin >> tmp.p1.x >> tmp.p1.y >> tmp.p2.x >> tmp.p2.y;
            seg.push_back(tmp);
        }

        for (unsigned int i=0; i<seg.size(); ++i)
            for (unsigned int j=i+1; j<seg.size(); ++j)
        {
            Segment a = seg[i], b = seg[j];
            Point p1 = a.p1, p2 = a.p2, p3 = b.p1, p4 = b.p2;

            Vector v1, v2, v3;
            v1 = MakeVec(p1, p2);//p1->p2
            v2 = MakeVec(p2, p4);
            v3 = MakeVec(p2, p3);
            float pro1, pro2;
            pro1 = ProVec(v1, v2);
            pro2 = ProVec(v1, v3);

            v1 = MakeVec(p3, p4);//p1->p2
            v2 = MakeVec(p4, p1);
            v3 = MakeVec(p4, p2);
            float pro3, pro4;
            pro3 = ProVec(v1, v2);
            pro4 = ProVec(v1, v3);

            if (pro1==0 || pro2==0 || (pro1*pro2<0 && pro3*pro4<0))
                ++ans;
        }
        cout << ans << endl;
        seg.clear();
    }
    return 0;
}
